<style type="text/css">
	.g_list .mytd{height:25px;}
	.title_pic{float: left;}
	.title{float:right;width:70%;}
	.text-center{font-size: 14px;}
.orderCount {
	border: 1px solid #8edbef;
	bottom: 1px;
	font-size: 12px;
	padding: 0 1px; 
	text-align: center;
	width: 20px;
}#beizhu img{width:100px;}
.biaoqian{cursor: pointer;border: 1px solid #8edbef;padding: 3px;border-radius: 2px;background: #8edbef;color: #fff;}
.zhankais{cursor: pointer;float: right;color:#f88e2d;font-size: 13px;}
.table-bordered{border: none;}
.pagination{margin-top:0px}
.col-sm-6 {width:70%;}
.row{margin-bottom: 20px;}
.mytd{
    /*font-weight: bold;*/
    font-size: 14px;
}
</style>
<script type="text/javascript"> 
jQuery.fn.rowspan = function(colIdx) { //封装的一个JQuery小插件  
return this.each(function(){ 
var that; 
$('tr', this).each(function(row) { 
$('td:eq('+colIdx+')', this).filter(':visible').each(function(col) { 
if (that!=null && $(this).html() == $(that).html()) { 
rowspan = $(that).attr("rowSpan"); 
if (rowspan == undefined) { 
$(that).attr("rowSpan",1); 
rowspan = $(that).attr("rowSpan"); } 
rowspan = Number(rowspan)+1; 
$(that).attr("rowSpan",rowspan); 
$(this).hide(); 
} else { 
that = this; 
}  
}); 
}); 
}); 
}

$(function() {
	//$(".g_list").rowspan(5);
	//$(".g_list").rowspan(6);
// 	$(".g_list").rowspan(7);
	$(".g_list").rowspan(8);
	$(".g_list").rowspan(9);
$(".zhankais").click(function(){
	var pd=$(this).text();
	var myrel=$(this).attr('rel');
	if(pd=='收回明细'){
		$(this).text('展开明细');
		$(this).removeClass('glyphicon-chevron-up');
		$(this).addClass('glyphicon-chevron-down');
		
	}else{
		$(this).removeClass('glyphicon-chevron-down');
		$(this).addClass('glyphicon-chevron-up');
		$(this).text('收回明细');
	}
	$(".zhankai"+myrel).slideToggle();
	}); 
}); 

</script>
             <form method="post" enctype="multipart/form-data" target="_blank" id="form-order">
                <div class="table-responsive">
                    <table class="table table-bordered" style="font-size:13px;">
                                <tbody>
                                <volist name="orderList" id="list">
									<?php
									$chaidan=$list['tag'] ? '&nbsp; ('.$list['tag'].')' : '';
									?>
                                    <tr style="border-bottom: 2px #fff solid;">
                                        <td class="text-center" style="<if condition='$list.order_status eq 3 || $list.order_status eq 5'>background:#BC9680;</if>">
                                        	<if condition='$list[shipping_status] neq 1'><input type="checkbox" name="order_id[]" title="已发货的订单不能批量编辑" value="{$list.order_id}"></if>
                                        	<input type="hidden" name="shipping_code[]" value="flat.flat">
											<span class="glyphicon glyphicon-chevron-up zhankais" rel="{$list.order_id}">收回明细</span>
                                        </td> 
                                        <td class="text-center" style="<if condition='$list.order_status eq 3 || $list.order_status eq 5'>background:#BC9680;</if>">单号：{$list.order_sn} {$chaidan}
											<if condition="$list['pay_status'] eq '0' "><span style="color:#ef811c;">（ 待支付 ）</span></if>
											<if condition="$list['pay_status'] eq '1'"><span style="color:green;">（ 已支付 ）</span></if>
											<?php if($list['dai_type'] == 2) echo '<span style="color:#ff9800">(特殊单)</span>'?>
											<if condition="$list['he_status'] eq 1">	<span  style="font-weight: bold;color:red;">合并订单</span></if>

										</td>
										<td class="text-center" style="<if condition='$list.order_status eq 3 || $list.order_status eq 5'>background:#BC9680;</if>">打印次数：{$list.dayin_store}</td>
                                        <td class="text-center" style="<if condition='$list.order_status eq 3 || $list.order_status eq 5'>background:#BC9680;</if>">状态：{$order_status[$list[order_status]]}
											<if condition="$list['pay_code'] eq 'cod'"><span style="color: #9318dc">( 货到付款 )</span></if>
											<if condition="$list['pay_code'] eq 'weixin'"><span style="color: green">( 在线付款 )</span></if>
										</td>
                                        <td class="text-center" style="<if condition='$list.order_status eq 3 || $list.order_status eq 5'>background:#BC9680;</if>">发货：{$shipping_status[$list[shipping_status]]}</td>
                                        <td class="text-center" style="<if condition='$list.order_status eq 3 || $list.order_status eq 5'>background:#BC9680;</if>"><if condition='$list.dayin_time neq "" '>
                                                打印时间：{$list.dayin_time|date='Y-m-d H:i',###}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                </if>下单时间：{$list.add_time|date='Y-m-d H:i',###}</td>
                                        <td class="text-right" style="<if condition='$list.order_status eq 3 || $list.order_status eq 5'>background:#BC9680;</if>">
                                            <if condition='$list.dai_type eq 1'>
											<span style="color:#ef811c;">(代客下单)</span>
											</if>
											<if condition="$list['fast_text']">
												<span class="btn btn-danger" >{$list.fast_text}</span>
											</if>
											
                                                 <a href="{:U('Seller/order/detail',array('order_id'=>$list['order_id']))}" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="查看详情"><i class="fa fa-eye"> 查看</i></a>
                                                 
                                                 <?php
													if($list['store_id'] ==4031 || $list['store_id'] ==4268){
												 ?>
												 <button id="syncact_button" type="button" onclick="sync_order({$list.order_id},'{$list.order_sn}',{$list.store_id});" class="btn btn-primary" style="margin-left:15px;"><i class="fa"></i>同步订单</button>
												 <?php
												 }
												 ?>
												 
												 <?php
													if(I('order_status')=='0'){
												 ?>
                                                 <a href="/index.php/Seller/Order/order_print/order_id/{$list.order_id}" target="_blank" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="打印订单"><i class="fa fa-print"></i>打印订单
                                                 </a>
												 <?php
												 }
												 ?>
                                               <!--  <if condition="($list['order_status'] eq 3) or ($list['order_status'] eq 5)">
                                                        <a href="{:U('Seller/order/delete_order',array('order_id'=>$list['order_id']))}"  data-toggle="tooltip" title="" class="btn btn-danger" data-original-title="删除"><i class="fa fa-trash-o"></i></a>
                                        	<else/>
                                        		<a href="javascript:void(0)" onclick="alert('该订单不得删除')" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="删除"><i class="fa fa-trash-o"></i></a>
                                        	</if> -->
                                                
                                        </td>
                                    </tr>

<tr class="zhankai{$list.order_id}" style="display:none;">
	<td class="text-center" colspan="10" style="padding:0;border: none;">
<table class="table table-bordered g_list" style="font-size:13px;width:100%;background:#f6fdff;">
<tr>
		<td width="200" class="mytds">产品名</td>
		<td width="110" class="mytds">单价</td> 
		<td width="90" class="mytds">数量</td>
		<td width="90" class="mytds">小计</td>
		<td width="80" class="mytds">平台扣点</td>
		<td width="80" class="mytds">平台扣费</td>
		<td width="80" class="mytds" style="color: #d0833f">供应价</td>
		<td width="80" style="color: green;">退货数</td>
		<td width="120" class="mytds">收件人</td>
		<td width="120" class="mytds">联系方式</td>
		<td width="130" class="mytds">总金额</td>
</tr>
<?php
$points_count=0; 
?>
<volist name="list.g_list" id="lists">
	<?php
	$huodong=$lists['prom_msg'] ? ' <span style="color:red">'.$lists['prom_msg'].'</span>' : '';
	?>
	<tr>
		<td style="text-align:left;">
			<img src="{$lists.original_img}" height="50" width="50" class="title_pic" onmouseover="layer.tips('<img src={$lists.original_img} width=180>',this,{tips: [1, '#EAF8FF']});" onmouseout="layer.closeAll();">
			<div class="title">{$lists.goods_name} {$huodong}</div>
			<div class="title" style="color:#8e8a8a;">{$lists.spec_key_name}</div>
			</td>
		<td class="mytd">￥{$lists.member_goods_price}</td> 
		<td class="mytd">{$lists.goods_num}</td>
		<td class="mytd">￥{$lists['member_goods_price']*$lists['goods_num']}</td>
		<td class="mytd">{$lists.points}%</td>
		<td class="mytd" style="color: blue;">{:sanwei(($lists['points']*$lists['member_goods_price']*$lists['goods_num'])/100)}</td>
		<td class="mytd" style="color: #d0833f;">{:sanwei(($lists['member_goods_price']) - ($lists['points']*$lists['member_goods_price'])/100)} </td>
		<td >{$lists.tuihuo_num}</td>
		<td class="mytd"><a href="javascript:;" onclick="consignee('{$list.consignee}')">{$list.consignee}</a>（{$list.company}）（{$list.biaoshi_xian}）</td>
		<td class="mytd">{$list.company_address}，{$list.mobile}</td>
		<td class="mytd" style="font-weight: bold;color: red;">{$lists.goods_kou_total} / <del style="color:#795548;font-weight:normal;">{$list.order_price.total_amount}</del></td>
	</tr>
</volist>  
<tr>
	<td class="text-right" colspan="5">
		 <div style="text-align: center;width:80%;float: left; font-weight: normal;color:#888c2c;">店铺优惠券：{$list.coupon_price}</div>
		平台总扣费：
	</td>
	<td class="text-center mytd" style="color: blue;font-weight: bold;">{$list.order_price.points_count}</td>
	<td class="text-center" style="color: blue;font-weight: bold;"></td>
	<td class="text-left mytd" colspan="2" style="font-weight: bold;color: green;">退货金额：{$list.tuihuo0}</td>
	<td class="text-right" style="font-weight: bold;">应收：</td>
	<td class="text-center mytd" style="color: red;font-weight: bold;">
	    {:$list['total_amount']-$list['order_price']['points_count']-$list['coupon_price']}
	    </td>
	</tr>
<tr>
	<td class="text-center" colspan="3" style="">
		<b>平台改单：</b>
					<if condition="$list.admin_note eq ''">
							<span style="color:#999;">未改单</span>
					<else/>
							<span style="color:red;">改价：<b>￥{$list.discount}</b>，{$list.admin_note|htmlspecialchars_decode}</span>
					</if>
	</td>
	<td class="text-left" colspan="3">
		<b>单据备注：</b>
		<span style="color:red;" id="beizhu">{$list.user_note|htmlspecialchars_decode}</span>
	</td>
	<td class="text-center" colspan="2" style="color:green;">入库：（{$list.ruku}件）</td>
    <td class="text-center" colspan="1" style="color:red;">发货：（{$list.chuku}件）</td>
	<td class="text-left" colspan="1" style="font-size: 28px;">
		标签数：<input  class="orderCount" style="font-size:28px;width:35px;" type="text" value="{$list.jian_count}" onkeyup="this.value=this.value.replace(/[^\d]/g,'0')" onchange="update_biaoqian('order','order_id','{$list.order_id}','jian_count',this)" onpaste="this.value=this.value.replace(/[^\d]/g,'')" {$list.biaoqian} />
				<i class="fa fa-print biaoqian" rel="{$list.order_id}">打印</i>
	</td>
	<!--<td class="text-center" colspan="1" > <a href="{:U('Order/order_print',array('order_id'=>$list['order_id']))}" target="_blank" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="打印订单">-->
	<!--                     <i class="fa fa-print"></i>打印订单</td>-->
</tr>
</table>
	</td>
</tr>

                                </volist>
                                </tbody>
                            </table>
                        </div>
                    </form>
                    <div> 
    <div class="navbar-form form-inline" style="display: flex; align-items: center;">
        <div style="display: flex; align-items: center;">
					<input type="checkbox" onclick="$('input[name=\'order_id\[\]\']').prop('checked', this.checked);" style="margin-top: 0; margin-right: 5px;">
					全选
				</div>
        <div class="form-group input-group" style="margin-left:20px;">
            <select id="func_id" class="form-control" style="width: 120px;">
                <option value="-1">请选择...</option> 
<!-- 				<option value="fahuo">一键发货</option> -->
<!--                <option value="confirm">确认订单</option> -->
				<option value="hebing">合并订单</option>
				<?php
				if(I('order_status')==0){
					echo '<option value="yongyou13">导出订单</option>';
				}else{
				echo '<option value="yongyou13s">导出订单</option>';
				}
				?>
				<option value="-1">————————</option>
                <option value="invalid">作废订单</option>
            </select>
        </div>
        <button id="act_button" type="button" onclick="act_submit();" class="btn btn-primary" style="margin-left:30px;"><i class="fa"></i> 确定</button>
		<button id="act_button" type="button" onclick="dayin('dingdan');" class="btn btn-primary" style="margin-left:30px;"><i class="fa"></i>批量打印</button>
		<?php
				if(I('order_status')==0){
				 echo '<button id="act_button" type="button" onclick="stockUp()" class="btn btn-danger" style="margin-left:60px;"><i class="fa"></i>订单备货</button>';
				}
				
				?>
		
		
    </div>
                        <div class="col-sm-6 text-right">{$page}</div>
                    </div>
<script>
    $(".pagination a").click(function(){
        var page = $(this).data('p');
        ajax_get_table('search-form2',page);
    });
    $(".biaoqian").click(function(){
		var obj=$(this).parent();
		var order_id=obj.find('i').attr('rel');
		var num=parseInt(obj.find('.orderCount').val());
		if(num<=0){
			layer.msg('标签数不能为0哦！', {icon: 5});return;
		}
		window.open('/index.php/Seller/Order/biaoqian_print/order_id/'+order_id);
    });

	
    //获取选中商品id
    function get_select_order_id_str() {
        if ($('input[name="order_id\[\]"]:checked').length == 0)
            return false;
        var goods_arr = Array();
        $('input[name="order_id\[\]"]:checked').each(function () {
            goods_arr.push($(this).val());
        });
        var order_id_str = goods_arr.join(',');
        return order_id_str
    }
	
    //获取选中商品标签数
    function biaoqians() {
        if ($('input[name="order_id\[\]"]:checked').length == 0)
            return false;
        var goods_arr = Array();var order_id='';var biaoqian=0,bq=0;
        $('input[name="order_id\[\]"]:checked').each(function () {
			order_id=$(this).val();
			bq=parseInt($('.zhankai'+order_id).find('.orderCount').val());
           biaoqian+=bq;
        });
		
        return biaoqian
    }

    function sync_order($order_id,$order_sn,$store_id) {
        //console.log($order_sn);
        var url = '/index.php/WXAPI/order/send_orders?order_id=';
        if($store_id == 4268){
            url = '/index.php/WXAPI/order/send_4268_orders?order_id=';
        }
        layer.confirm('确认同步订单号为'+$order_sn+'的订单吗?', {
			  title:'系统提醒！',
			  btn: ['确定','取消'] //按钮
			}, function(){
            $.ajax({
                type: "GET",
                url: url+$order_id,
                success: function (data) {
                    var datas = JSON.parse(data);
					if(datas.put_data=='200'){
						layer.alert('订单同步成功！', {icon: 6},function(e){
							window.location.reload();
						});
					}else{
						layer.alert('订单同步失败！', {icon: 5});
					}
                },
                error:function(){
                    layer.alert('网络异常', {icon: 2,time: 3000});
                }
            });
            layer.close();
		});
    }
    
    function consignee(key){
        $('#consignee').val(key)
        ajax_get_table('search-form2',1);
        $('#consignee').val('')
    }
    
    //批量操作提交
    function act_submit() {
        //prompt层
		var type=$("#func_id").val();
        var ids = get_select_order_id_str();
		var biaoqian = biaoqians();
            console.log(type)
			if(type=='yongyou13s' || type=='yongyou13'){
				var order_sn=$('#order_sn').val(),
						consignee=$('#consignee').val(),
						timegap=$('#add_time').val(),
						goods_name=$('#goods_name').val(),
						order_status=$('#order_status').val(),
						dayin_store=$('#dayin_store').val();

				var where='?order_sn='+order_sn+'&consignee='+consignee+'&timegap='+timegap+'&goods_name='+goods_name+'&order_status='+order_status+'&dayin_store='+dayin_store;

				location.href='/Seller/Order/yongyou13s'+where;
				return false;
			}


        if (ids == false) {
            layer.alert('请勾选要操作的订单', {icon: 2});
            return;
        }
		if(type=='-1'){
			layer.alert('请选择操作类型', {icon: 2});
			return;
		}
		
		if(type=='hebing'){
			layer.confirm('合并订单后，一定要重新打印标签！', {
			  title:'系统警告！',
			  btn: ['确定合并','取消'] //按钮
			}, function(){
		if(biaoqian!=0){layer.alert('已打标签订单，不允许合并。！', {icon: 2});return;}
		
        var text = prompt('请输入操作备注', '填写操作备注,可不填');
        if (text != null && text != "") {
            $.ajax({
                type: "POST",
                url: "/index.php/Seller/order/order_actions",//+tab,window.location.reload();
                data: {type: type,order_ids: ids, reason: text},
                success: function (data) {
					if(data=='0'){
						layer.alert('订单修改成功！', {icon: 6},function(e){
							window.location.reload();
						});
					}else if(data=='-1'){
						layer.alert('合并失败！存在不同的收货人或不同支付方式！', {icon: 5});
					}else{
						layer.alert('系统错误！', {icon: 5});
					}
                },
                error:function(){
                    layer.alert('网络异常', {icon: 2,time: 3000});
                }
            });
        }
			});
		}else if(type=='invalid'){
        var text = prompt('请输入操作备注', '填写操作备注,可不填');
        if (text != null && text != "") {
            $.ajax({
                type: "POST",
                url: "/index.php/Seller/order/order_actions",//+tab,window.location.reload();
                data: {type: type,order_ids: ids, reason: text},
                success: function (data) {
					if(data=='0'){
						layer.alert('订单修改成功！', {icon: 6},function(e){
							window.location.reload();
						});
					}else if(data=='-1'){
						layer.alert('合并失败！存在不同的收货人！', {icon: 5});
					}else{
						layer.alert('系统错误！', {icon: 5});
					}
                },
                error:function(){
                    layer.alert('网络异常', {icon: 2,time: 3000});
                }
            });
        }
		}else if(type=='yongyou13'){
			location.href='/Seller/Order/yongyou13/ids/'+ids;
		}
    }
    
    
    function stockUp(){
         var ids = get_select_order_id_str();
         if (ids == false) {
            layer.alert('请勾选要操作的订单', {icon: 2});
            return;
            }
          layer.confirm('确认备货订单嘛', {
			  title:'系统提醒！',
			  btn: ['确定','取消'] //按钮
			}, function(){
             $.ajax({
                type: "POST",
                url: "/Seller/Order/stockUp",//+tab,window.location.reload();
                data: {order_ids: ids},
                success: function (data) {
                    if(data.code == 1){
                        layer.alert(data.msg, {icon: 6},function(e){
							window.location.reload();
						});
                    }else{
                       layer.alert(data.msg, {icon: 2,time: 3000}); 
                    }
					 
                },
                error:function(){
                    layer.alert('网络异常', {icon: 2,time: 3000});
                }
            });
            layer.close();
		});
       
    }
</script>